<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="java.util.List" %>
<%@ page import="com.cinsea.common.Env" %>
<%@ include file="/common/common.jsp" %>
<%
    response.setHeader("cache-control", "no-cache");
    response.setHeader("pragma", "no-cache");
    response.setHeader("expires", "Mon 1 Jan 1990 00:00:00 GMT");
    JdbcDao jdbcDao = Env.getBean("jdbcDao");

    String gzlid = StringUtil.null2String(request.getParameter("pgzlid"));
    String year = StringUtil.null2String(request.getParameter("pyear"));
    String month = StringUtil.null2String(request.getParameter("pmonth"));
    String reportUrl = "/ReportServer?reportlet=/zbc/07_gongshi/03_gongshi_3_m.cpt&op=write&pgzlid="+
        gzlid+"&pyear="+year+"&pmonth="+month;
    String sql = "select userid from ut_zbc_gongshi5 where gzlid=? and year=? and month=?";
    try{
        List<Map> userList = jdbcDao.queryForList(sql,new Object[]{gzlid,year,month});
        sql = "select projectleader,projectleader1,xmfzrc from ut_workorderoffer where processid=?";
        Map userInfo = jdbcDao.queryForMap(sql,new Object[]{gzlid});
        List users = new ArrayList();
        users.add(userInfo.get("projectleader"));
        if(userInfo.get("projectleader1")!=null){
            users.add(userInfo.get("projectleader1"));
        }
        if(userInfo.get("xmfzrc")!=null){
            String xmfzrc = StringUtil.null2String(userInfo.get("xmfzrc"));
            String[] xmfzrcs = xmfzrc.split(",");
            for(String str : xmfzrcs){
                users.add(str);
            }
        }
        List changeUser = new ArrayList();
        if(userList.size()>0){
            for(int i=0; i<users.size(); i++){
                String temp = StringUtil.null2String(users.get(i));
                for(int j=0; j<userList.size(); j++){
                    if(!temp.equals(userList.get(j))){
                        changeUser.add(temp);
                    }
                }
            }
        }else{
            changeUser.addAll(users);
            for(int i=0; i<changeUser.size(); i++){
                System.out.println(changeUser.get(i).toString());
            }
        }
        for(int i =0; i<changeUser.size(); i++){
            sql = "insert into ut_zbc_gongshi5(year,month,gzlid,userid) values("+
                    year+","+
                    month+",'"+
                    gzlid+"','"+
                    changeUser.get(i).toString()+"')";
            jdbcDao.update(sql);
        }
        request.getRequestDispatcher(reportUrl).forward(request,response);
    }catch(Exception e){
        e.printStackTrace();
    }

%>
<html>
<head>
    <%@ include file="/common/head.jsp" %>
    <title>R\&D人员工时统计</title>
</head>
<body>

</body>

</html>
